import { GameConfig } from "../../Script/common/GameConfig";
import { lang_zh, LANG_ENUM } from "./zh";

const { ccclass, property } = cc._decorator;

@ccclass
export default class LocalizedLabel extends cc.Component {
    @property(cc.String)
    langKey: string = "";

    onLoad() {

    }
    onEnable() {
        this.update();
        let label: cc.Label | cc.RichText;
        label = this.node.getComponent(cc.RichText) ||this.node.getComponent(cc.Label);
        if(lang_zh.hasOwnProperty(this.langKey)){
            if(label instanceof cc.RichText){//富文本 设置加粗
                label.string = `<b> ${lang_zh[this.langKey][GameConfig.languages]} </b>`
            }else{
                label.string = ` ${lang_zh[this.langKey][GameConfig.languages]} `
            }
        }
    }

    onDisable() {
    }

    public update(): void {

    }
};